//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI;

namespace CommunityServer.ControlPanel.Controls
{
	public class ControlPanelSelectedNavigation : Control
	{
		protected string SelectedTabQueryStringKey = "SelectedTab";
		protected string SelectedNavItemQueryStringKey = "SelectedNavItem";

		public ControlPanelSelectedNavigation()
		{
		}

		protected override void OnLoad(EventArgs e)
		{
			if (Page.Request.QueryString[SelectedNavItemQueryStringKey] != null)
				SelectedNavItem = Page.Request.QueryString[SelectedNavItemQueryStringKey];

			if (Page.Request.QueryString[SelectedTabQueryStringKey] != null)
				SelectedTab = Page.Request.QueryString[SelectedTabQueryStringKey];
			
			if (!CommunityServer.Components.Globals.IsNullorEmpty(this.SelectedTab))
				Context.Items["ControlPanelSelectedTab"] = this.SelectedTab;

			if (!CommunityServer.Components.Globals.IsNullorEmpty(this.SelectedNavItem))
				Context.Items["ControlPanelSelectedNavItem"] = this.SelectedNavItem;

			base.OnLoad (e);
		}

		private string _selectedTab = null;
		public string SelectedTab
		{
			get { return _selectedTab;}
			set
			{
				_selectedTab = value;
			}
		}

		private string _selectedNavItem = null;
		public string SelectedNavItem
		{
			get { return _selectedNavItem;}
			set
			{
				_selectedNavItem = value;
			}
		}
	}
}
